package com.xtxb.utils.log;

import com.xtxb.utils.log.config.Configer;
import com.xtxb.utils.log.config.LoggerConf;
import com.xtxb.utils.log.impl.FileOutLogger;
import com.xtxb.utils.log.impl.SystemOutLogger;

/**
 * 作者: xtxb-fedora
 * <p>
 * 日期: 2021年01月20日-上午11:14
 * <p>
 * 版权说明：xtxb
 * <p>
 * DebugLogger 实现类的代理
 */
public class SuperLogger implements DebugLogger, Configer {
    private Class logedClass=null;
    private DebugLogger logger=null;

    public SuperLogger(Class logedClass){
        this.logedClass=logedClass;
    }
    @Override
    public void initLogger(){
        logger=null;
        if(LoggerConf.getLogType()==0){
            logger=new SystemOutLogger(logedClass);
        }else {
            logger=new FileOutLogger(logedClass);
        }
    }

    @Override
    public void message(Object msg, Throwable t) {
        if(logger!=null && LoggerConf.printLog())
            logger.message(msg,t);
    }
}
